package com.guos.redis;

import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

import java.util.concurrent.TimeUnit;

/**
 * 每一行代码，都是改变世界的力量
 *
 * @author 郭帅
 * @date 2022/7/2 4:16 下午
 */
public class RedissonLock {

    public static void main(String[] args) throws InterruptedException {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
        RedissonClient redisson = Redisson.create(config);
        RLock rLock = redisson.getLock("guoshuai3");
        for (int i = 0; i < 5; i++) {
            boolean bool = rLock.tryLock(300, TimeUnit.HOURS);
            System.out.println(bool);
        }
    }

}
